using System;
using System.Collections.Generic;
using System.ByteBuffer;
using tools;

namespace thirteen
{
    /// <summary>
    /// generate by msg tool
    /// 进入房间结果
    /// </summary>
	public class ResEnterRoomMsg : ResMessage
	{
		//房间座位信息
		public List<SeatInfo> seats = new List<SeatInfo>();
		
		//是否游戏中 (0:否，非0:是)
		public int gaming;
		//房间号
		public int roomId;
		//房间创建人
		public long owner;
		//总局数
		public int rounds;
		//当前局数
		public int curRound;

        public ResEnterRoomMsg() { }

        public ResEnterRoomMsg(int gaming, int roomId, long owner, int rounds, int curRound)
        {
            this.gaming = gaming;
            this.roomId = roomId;
            this.owner = owner;
            this.rounds = rounds;
            this.curRound = curRound;
        }

        
		public void write(object obj)
		{
            ByteBuffer b = obj as ByteBuffer;
			b.PushInt(seats.Count);

			foreach (var element in seats)
			{
				element.write(b);
			}
			b.PushInt(gaming);
			b.PushInt(roomId);
			b.PushLong(owner);
			b.PushInt(rounds);
			b.PushInt(curRound);
			
		}

	    public void read(object obj)
		{
            MyConverter b = obj as MyConverter;
			int seats_length = b.toInt32();
			for (int i = 0; i < seats_length; ++i)
			{
				var dto = new SeatInfo();
				dto.read(b);
				seats.Add(dto);
			}
			gaming = b.toInt32();
			roomId = b.toInt32();
			owner = b.toInt64();
			rounds = b.toInt32();
			curRound = b.toInt32();
			
		}

		public int Id
		{
            get { return 621207; }
		}

        public String Desc
        {
            get { return "进入房间结果"; }
        }
	}
}